package com.matt.domain.record;

import com.matt.commons.model.Model;
import com.matt.domain.Children;
import com.matt.foundation.utils.DateUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.math.BigInteger;
import java.util.Date;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2017/7/21
 * *******************************
 */
@Entity
@Data
@Table(name = "check_record"
//        ,
//        uniqueConstraints = {
//                @UniqueConstraint(columnNames = {
//                        "childrenId",
//                        "checkinDateStr",
//                        "checkinIndex"
//                })
//        }
        )
@EqualsAndHashCode(callSuper = true)
public class CheckRecord extends Model {

    @Column(columnDefinition = "varchar(32) COMMENT '宝宝id'")
    private String childrenId;

    @Column(columnDefinition = "datetime COMMENT '签到时间'")
    private Date checkInTime;

    @Column(columnDefinition = "varchar(1000) COMMENT '签到记录媒体地址'")
    private String checkInMediaUrl;

    @Column(columnDefinition = "varchar(32) COMMENT '签到人id'")
    private String checkInStaffId;

    @Column(columnDefinition = "datetime COMMENT '签退时间'")
    private Date checkOutTime;

    @Column(columnDefinition = "varchar(1000) COMMENT '签退记录媒体地址'")
    private String checkOutMediaUrl;

    @Column(columnDefinition = "varchar(32) COMMENT '签退人id'")
    private String checkOutStaffId;

    @Column(columnDefinition = "int default 0 COMMENT '签到渠道 1，web，2，pad,3：考勤机'")
    private Integer checkType;

    @Column(columnDefinition = "int default 1 COMMENT '用户类型 幼儿1.员工2.家长3'")
    private Integer userType;

    @Column(columnDefinition = "int default 0 COMMENT '签到状态 0:缺席,1:入园,2:离园,3:拒绝入园,4:请假,5迟到，6早退' ")
    private Integer status = 0;


    @Column(columnDefinition = "int default 0 COMMENT '健康状态 0，健康，1，不健康'")
    private Integer healthyStatus = 0;

    @Column(columnDefinition = "varchar(255) COMMENT '异常情况'")
    private String exceptionName;
    @Column(columnDefinition = "varchar(255) COMMENT '温度'")
    private String temperature;
    @Column(columnDefinition = "varchar(255) COMMENT '温度1'")
    private String temperature1;

    @Column(columnDefinition = "varchar(255) COMMENT '疾病名称'")
    private String sickName;

    @Column(columnDefinition = "varchar(255) COMMENT '特殊记录'")
    private String specialRecord;

    @Column(columnDefinition = "bigint default 0 COMMENT '持续时长'")
    private BigInteger duration = BigInteger.ZERO;

    @Column(columnDefinition = "varchar(20) COMMENT '身高'")
    private String height;

    @Column(columnDefinition = "varchar(20) COMMENT '体重'")
    private String weight;

    @Column(columnDefinition = "varchar(20) COMMENT '头围'")
    private String header;

    @Column(columnDefinition = "varchar(32) COMMENT '监护人'")
    private String relateId;

    @Column(columnDefinition = "varchar(255) COMMENT '监护名称'")
    private String relateName;

    @Column(columnDefinition = "varchar(255) COMMENT '监护人照片'")
    private String relateHeadImage;

    @Column(columnDefinition = "datetime COMMENT '创建时间'")
    private Date created = new Date();

    @Column(columnDefinition = "varchar(255) COMMENT '考勤机ID'")
    private String checkerId;

    @Column(columnDefinition = "varchar(255) COMMENT '考勤机名称'")
    private String checkerAddress;

    @Column(columnDefinition = "varchar(255) COMMENT '卡号'")
    private String cardNo = "";

    @Column(columnDefinition = "varchar(16) COMMENT '日期字符串，用来group'")
    private String groupFlag;

    @Column(columnDefinition = "varchar(255) COMMENT '班级id'")
    private String classesId;

    public CheckRecord(){
        this.groupFlag = DateUtil.convertStr(this.created);
    }

    public static CheckRecord of(CheckRecord record ,Children children){
        CheckRecord checkRecord = new CheckRecord();

        return checkRecord;
    }
}
